{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Options and Settings ：http://pandas.pydata.org/pandas-docs/stable/options.html\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.model_selection import train_test_split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#http://pandas.pydata.org/pandas-docs/stable/options.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.options.display.max_rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.display.max_rows = 999"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "999"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.options.display.max_rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "999"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.get_option(\"display.max_rows\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "102"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option(\"display.max_rows\", 102)\n",
    "pd.get_option(\"display.max_rows\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "102\n",
      "'Pattern matched multiple keys'\n"
     ]
    }
   ],
   "source": [
    "try:\n",
    "    print(pd.get_option(\"display.max_rows\"))\n",
    "    print(pd.get_option(\"column\"))\n",
    "except KeyError as e:\n",
    "    print(e)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.794484</td>\n",
       "      <td>0.723458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.636547</td>\n",
       "      <td>0.739472</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.760393</td>\n",
       "      <td>0.725509</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.840610</td>\n",
       "      <td>1.973087</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.745996</td>\n",
       "      <td>-0.038322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-1.488807</td>\n",
       "      <td>0.460783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.907616</td>\n",
       "      <td>0.994660</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1\n",
       "0 -0.794484  0.723458\n",
       "1 -0.636547  0.739472\n",
       "2  1.760393  0.725509\n",
       "3 -0.840610  1.973087\n",
       "4  0.745996 -0.038322\n",
       "5 -1.488807  0.460783\n",
       "6 -0.907616  0.994660"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = pd.DataFrame(np.random.randn(7,2))\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "#1）display.max_rows and display.max_columns sets the maximum number of rows and columns displayed when a frame is pretty-printed. Truncated lines are replaced by an ellipsis.\n",
    "pd.set_option('max_rows', 5) #  当你的数据有几万行的时候，这个是个好方法，只显示几行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.794484</td>\n",
       "      <td>0.723458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.636547</td>\n",
       "      <td>0.739472</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-1.488807</td>\n",
       "      <td>0.460783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.907616</td>\n",
       "      <td>0.994660</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           0         1\n",
       "0  -0.794484  0.723458\n",
       "1  -0.636547  0.739472\n",
       "..       ...       ...\n",
       "5  -1.488807  0.460783\n",
       "6  -0.907616  0.994660\n",
       "\n",
       "[7 rows x 2 columns]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>20</th>\n",
       "      <th>21</th>\n",
       "      <th>22</th>\n",
       "      <th>23</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.599387</td>\n",
       "      <td>0.289593</td>\n",
       "      <td>1.558081</td>\n",
       "      <td>0.970624</td>\n",
       "      <td>-0.897870</td>\n",
       "      <td>0.805790</td>\n",
       "      <td>-0.812740</td>\n",
       "      <td>0.606642</td>\n",
       "      <td>0.670668</td>\n",
       "      <td>-1.305335</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.673693</td>\n",
       "      <td>0.154182</td>\n",
       "      <td>0.035203</td>\n",
       "      <td>0.150519</td>\n",
       "      <td>0.637302</td>\n",
       "      <td>-0.017877</td>\n",
       "      <td>-1.045139</td>\n",
       "      <td>0.548228</td>\n",
       "      <td>0.632578</td>\n",
       "      <td>-2.663249</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.148402</td>\n",
       "      <td>1.866124</td>\n",
       "      <td>-0.854599</td>\n",
       "      <td>1.163636</td>\n",
       "      <td>-1.335766</td>\n",
       "      <td>-1.006370</td>\n",
       "      <td>-0.162301</td>\n",
       "      <td>-0.888061</td>\n",
       "      <td>-0.915732</td>\n",
       "      <td>0.850238</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.379261</td>\n",
       "      <td>1.691596</td>\n",
       "      <td>-0.136399</td>\n",
       "      <td>0.133437</td>\n",
       "      <td>-0.890038</td>\n",
       "      <td>0.585146</td>\n",
       "      <td>0.187453</td>\n",
       "      <td>0.497648</td>\n",
       "      <td>-0.158447</td>\n",
       "      <td>-1.254569</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.593653</td>\n",
       "      <td>0.417327</td>\n",
       "      <td>-1.390471</td>\n",
       "      <td>-0.553461</td>\n",
       "      <td>0.467318</td>\n",
       "      <td>1.112786</td>\n",
       "      <td>0.618739</td>\n",
       "      <td>1.167665</td>\n",
       "      <td>-1.405456</td>\n",
       "      <td>1.494369</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.419363</td>\n",
       "      <td>-2.009177</td>\n",
       "      <td>-0.533416</td>\n",
       "      <td>-0.577054</td>\n",
       "      <td>0.244213</td>\n",
       "      <td>0.633771</td>\n",
       "      <td>-1.346559</td>\n",
       "      <td>-0.422427</td>\n",
       "      <td>-0.126244</td>\n",
       "      <td>-0.346292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.202695</td>\n",
       "      <td>1.873356</td>\n",
       "      <td>-0.728619</td>\n",
       "      <td>-0.653058</td>\n",
       "      <td>0.523329</td>\n",
       "      <td>-0.147055</td>\n",
       "      <td>-1.153106</td>\n",
       "      <td>-0.105790</td>\n",
       "      <td>1.244541</td>\n",
       "      <td>0.332515</td>\n",
       "      <td>...</td>\n",
       "      <td>1.067310</td>\n",
       "      <td>0.872962</td>\n",
       "      <td>0.580227</td>\n",
       "      <td>-0.170809</td>\n",
       "      <td>-0.171694</td>\n",
       "      <td>1.424603</td>\n",
       "      <td>0.842523</td>\n",
       "      <td>0.126850</td>\n",
       "      <td>-1.015249</td>\n",
       "      <td>-0.666503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.565304</td>\n",
       "      <td>0.148934</td>\n",
       "      <td>-0.215582</td>\n",
       "      <td>1.127347</td>\n",
       "      <td>-0.468585</td>\n",
       "      <td>-0.184409</td>\n",
       "      <td>-0.283460</td>\n",
       "      <td>-1.620499</td>\n",
       "      <td>0.289517</td>\n",
       "      <td>0.959370</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.024343</td>\n",
       "      <td>-2.786257</td>\n",
       "      <td>-1.453448</td>\n",
       "      <td>0.401706</td>\n",
       "      <td>0.213548</td>\n",
       "      <td>0.998372</td>\n",
       "      <td>0.363432</td>\n",
       "      <td>2.097301</td>\n",
       "      <td>-0.509931</td>\n",
       "      <td>0.004823</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         0         1         2         3         4         5         6   \\\n",
       "0  0.599387  0.289593  1.558081  0.970624 -0.897870  0.805790 -0.812740   \n",
       "1  0.148402  1.866124 -0.854599  1.163636 -1.335766 -1.006370 -0.162301   \n",
       "2  1.593653  0.417327 -1.390471 -0.553461  0.467318  1.112786  0.618739   \n",
       "3 -0.202695  1.873356 -0.728619 -0.653058  0.523329 -0.147055 -1.153106   \n",
       "4  0.565304  0.148934 -0.215582  1.127347 -0.468585 -0.184409 -0.283460   \n",
       "\n",
       "         7         8         9     ...           20        21        22  \\\n",
       "0  0.606642  0.670668 -1.305335    ...    -0.673693  0.154182  0.035203   \n",
       "1 -0.888061 -0.915732  0.850238    ...    -1.379261  1.691596 -0.136399   \n",
       "2  1.167665 -1.405456  1.494369    ...    -1.419363 -2.009177 -0.533416   \n",
       "3 -0.105790  1.244541  0.332515    ...     1.067310  0.872962  0.580227   \n",
       "4 -1.620499  0.289517  0.959370    ...    -0.024343 -2.786257 -1.453448   \n",
       "\n",
       "         23        24        25        26        27        28        29  \n",
       "0  0.150519  0.637302 -0.017877 -1.045139  0.548228  0.632578 -2.663249  \n",
       "1  0.133437 -0.890038  0.585146  0.187453  0.497648 -0.158447 -1.254569  \n",
       "2 -0.577054  0.244213  0.633771 -1.346559 -0.422427 -0.126244 -0.346292  \n",
       "3 -0.170809 -0.171694  1.424603  0.842523  0.126850 -1.015249 -0.666503  \n",
       "4  0.401706  0.213548  0.998372  0.363432  2.097301 -0.509931  0.004823  \n",
       "\n",
       "[5 rows x 30 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#2） display.expand_frame_repr allows for the the representation of dataframes to stretch across pages, wrapped over the full column vs row-wise.\n",
    "#当行放不下的时候，可以用expand_frame_repr实现,这个功能感觉没用\n",
    "df2 = pd.DataFrame(np.random.randn(5, 30))\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.set_option('expand_frame_repr', True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>20</th>\n",
       "      <th>21</th>\n",
       "      <th>22</th>\n",
       "      <th>23</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.599387</td>\n",
       "      <td>0.289593</td>\n",
       "      <td>1.558081</td>\n",
       "      <td>0.970624</td>\n",
       "      <td>-0.897870</td>\n",
       "      <td>0.805790</td>\n",
       "      <td>-0.812740</td>\n",
       "      <td>0.606642</td>\n",
       "      <td>0.670668</td>\n",
       "      <td>-1.305335</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.673693</td>\n",
       "      <td>0.154182</td>\n",
       "      <td>0.035203</td>\n",
       "      <td>0.150519</td>\n",
       "      <td>0.637302</td>\n",
       "      <td>-0.017877</td>\n",
       "      <td>-1.045139</td>\n",
       "      <td>0.548228</td>\n",
       "      <td>0.632578</td>\n",
       "      <td>-2.663249</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.148402</td>\n",
       "      <td>1.866124</td>\n",
       "      <td>-0.854599</td>\n",
       "      <td>1.163636</td>\n",
       "      <td>-1.335766</td>\n",
       "      <td>-1.006370</td>\n",
       "      <td>-0.162301</td>\n",
       "      <td>-0.888061</td>\n",
       "      <td>-0.915732</td>\n",
       "      <td>0.850238</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.379261</td>\n",
       "      <td>1.691596</td>\n",
       "      <td>-0.136399</td>\n",
       "      <td>0.133437</td>\n",
       "      <td>-0.890038</td>\n",
       "      <td>0.585146</td>\n",
       "      <td>0.187453</td>\n",
       "      <td>0.497648</td>\n",
       "      <td>-0.158447</td>\n",
       "      <td>-1.254569</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.593653</td>\n",
       "      <td>0.417327</td>\n",
       "      <td>-1.390471</td>\n",
       "      <td>-0.553461</td>\n",
       "      <td>0.467318</td>\n",
       "      <td>1.112786</td>\n",
       "      <td>0.618739</td>\n",
       "      <td>1.167665</td>\n",
       "      <td>-1.405456</td>\n",
       "      <td>1.494369</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.419363</td>\n",
       "      <td>-2.009177</td>\n",
       "      <td>-0.533416</td>\n",
       "      <td>-0.577054</td>\n",
       "      <td>0.244213</td>\n",
       "      <td>0.633771</td>\n",
       "      <td>-1.346559</td>\n",
       "      <td>-0.422427</td>\n",
       "      <td>-0.126244</td>\n",
       "      <td>-0.346292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.202695</td>\n",
       "      <td>1.873356</td>\n",
       "      <td>-0.728619</td>\n",
       "      <td>-0.653058</td>\n",
       "      <td>0.523329</td>\n",
       "      <td>-0.147055</td>\n",
       "      <td>-1.153106</td>\n",
       "      <td>-0.105790</td>\n",
       "      <td>1.244541</td>\n",
       "      <td>0.332515</td>\n",
       "      <td>...</td>\n",
       "      <td>1.067310</td>\n",
       "      <td>0.872962</td>\n",
       "      <td>0.580227</td>\n",
       "      <td>-0.170809</td>\n",
       "      <td>-0.171694</td>\n",
       "      <td>1.424603</td>\n",
       "      <td>0.842523</td>\n",
       "      <td>0.126850</td>\n",
       "      <td>-1.015249</td>\n",
       "      <td>-0.666503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.565304</td>\n",
       "      <td>0.148934</td>\n",
       "      <td>-0.215582</td>\n",
       "      <td>1.127347</td>\n",
       "      <td>-0.468585</td>\n",
       "      <td>-0.184409</td>\n",
       "      <td>-0.283460</td>\n",
       "      <td>-1.620499</td>\n",
       "      <td>0.289517</td>\n",
       "      <td>0.959370</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.024343</td>\n",
       "      <td>-2.786257</td>\n",
       "      <td>-1.453448</td>\n",
       "      <td>0.401706</td>\n",
       "      <td>0.213548</td>\n",
       "      <td>0.998372</td>\n",
       "      <td>0.363432</td>\n",
       "      <td>2.097301</td>\n",
       "      <td>-0.509931</td>\n",
       "      <td>0.004823</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         0         1         2         3         4         5         6   \\\n",
       "0  0.599387  0.289593  1.558081  0.970624 -0.897870  0.805790 -0.812740   \n",
       "1  0.148402  1.866124 -0.854599  1.163636 -1.335766 -1.006370 -0.162301   \n",
       "2  1.593653  0.417327 -1.390471 -0.553461  0.467318  1.112786  0.618739   \n",
       "3 -0.202695  1.873356 -0.728619 -0.653058  0.523329 -0.147055 -1.153106   \n",
       "4  0.565304  0.148934 -0.215582  1.127347 -0.468585 -0.184409 -0.283460   \n",
       "\n",
       "         7         8         9     ...           20        21        22  \\\n",
       "0  0.606642  0.670668 -1.305335    ...    -0.673693  0.154182  0.035203   \n",
       "1 -0.888061 -0.915732  0.850238    ...    -1.379261  1.691596 -0.136399   \n",
       "2  1.167665 -1.405456  1.494369    ...    -1.419363 -2.009177 -0.533416   \n",
       "3 -0.105790  1.244541  0.332515    ...     1.067310  0.872962  0.580227   \n",
       "4 -1.620499  0.289517  0.959370    ...    -0.024343 -2.786257 -1.453448   \n",
       "\n",
       "         23        24        25        26        27        28        29  \n",
       "0  0.150519  0.637302 -0.017877 -1.045139  0.548228  0.632578 -2.663249  \n",
       "1  0.133437 -0.890038  0.585146  0.187453  0.497648 -0.158447 -1.254569  \n",
       "2 -0.577054  0.244213  0.633771 -1.346559 -0.422427 -0.126244 -0.346292  \n",
       "3 -0.170809 -0.171694  1.424603  0.842523  0.126850 -1.015249 -0.666503  \n",
       "4  0.401706  0.213548  0.998372  0.363432  2.097301 -0.509931  0.004823  \n",
       "\n",
       "[5 rows x 30 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>foo</td>\n",
       "      <td>bar</td>\n",
       "      <td>bim</td>\n",
       "      <td>uncomfortably long string</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>horse</td>\n",
       "      <td>cow</td>\n",
       "      <td>banana</td>\n",
       "      <td>apple</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0    1       2                          3\n",
       "0    foo  bar     bim  uncomfortably long string\n",
       "1  horse  cow  banana                      apple"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#3）字符串太长了，显示不好看，重改\n",
    "#display.max_colwidth sets the maximum width of columns. Cells of this length or longer will be truncated with an ellipsis.\n",
    "df3 = pd.DataFrame(np.array([['foo', 'bar', 'bim', 'uncomfortably long string'],\n",
    "                            ['horse', 'cow', 'banana', 'apple']]))\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>foo</td>\n",
       "      <td>bar</td>\n",
       "      <td>bim</td>\n",
       "      <td>uncomfortably lo...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>horse</td>\n",
       "      <td>cow</td>\n",
       "      <td>banana</td>\n",
       "      <td>apple</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0    1       2                    3\n",
       "0    foo  bar     bim  uncomfortably lo...\n",
       "1  horse  cow  banana                apple"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('max_colwidth', 20)\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>foo</td>\n",
       "      <td>bar</td>\n",
       "      <td>bim</td>\n",
       "      <td>un...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>horse</td>\n",
       "      <td>cow</td>\n",
       "      <td>ba...</td>\n",
       "      <td>apple</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0    1      2      3\n",
       "0    foo  bar    bim  un...\n",
       "1  horse  cow  ba...  apple"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('max_colwidth', 6)\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "#4)\n",
    "#mode.chained_assignment:  https://pandas.pydata.org/pandas-docs/stable/options.html\n",
    "#Controls SettingWithCopyWarning: ‘raise’, ‘warn’, or None. Raise an exception, warn, or no action if trying to use chained assignment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      0    1    2    3    4    5    6    7    8    9\n",
       "0   0.0  1.0  NaN  1.0  1.0  0.0  0.0  0.0  NaN  NaN\n",
       "1   NaN  NaN  1.0  0.0  1.0  1.0  1.0  0.0  0.0  1.0\n",
       "2   1.0  0.0  1.0  1.0  NaN  0.0  1.0  0.0  1.0  1.0\n",
       "3   0.0  1.0  NaN  1.0  1.0  NaN  1.0  NaN  0.0  1.0\n",
       "..  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...\n",
       "6   1.0  NaN  1.0  1.0  NaN  0.0  0.0  0.0  1.0  1.0\n",
       "7   NaN  0.0  1.0  0.0  0.0  NaN  NaN  NaN  1.0  0.0\n",
       "8   1.0  1.0  0.0  NaN  NaN  NaN  0.0  NaN  NaN  1.0\n",
       "9   0.0  0.0  1.0  0.0  0.0  1.0  0.0  NaN  NaN  1.0\n",
       "\n",
       "[10 rows x 10 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#5) 统计每一列中非零元素的个数\n",
    "\n",
    "#np.random.choice():\n",
    "#https://blog.csdn.net/IAMoldpan/article/details/78707140\n",
    "#https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.choice.html\n",
    "\n",
    "\n",
    "#display.max_info_rows: df.info() will usually show null-counts for each column. For large frames this can be quite slow. max_info_rows and max_info_cols limit this null check only to frames with smaller dimensions then specified. Note that you can specify the option\n",
    "#df.info(null_counts=True) to override on showing a particular frame\n",
    "df4 = pd.DataFrame(np.random.choice([0,1,np.nan], size=(10, 10)))\n",
    "pd.set_option('max_rows', 8)\n",
    "df4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.set_option('max_info_rows', 11)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 10 entries, 0 to 9\n",
      "Data columns (total 10 columns):\n",
      "0    8 non-null float64\n",
      "1    8 non-null float64\n",
      "2    7 non-null float64\n",
      "3    9 non-null float64\n",
      "4    6 non-null float64\n",
      "5    6 non-null float64\n",
      "6    9 non-null float64\n",
      "7    4 non-null float64\n",
      "8    6 non-null float64\n",
      "9    8 non-null float64\n",
      "dtypes: float64(10)\n",
      "memory usage: 880.0 bytes\n"
     ]
    }
   ],
   "source": [
    "df4.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 10 entries, 0 to 9\n",
      "Data columns (total 10 columns):\n",
      "0    float64\n",
      "1    float64\n",
      "2    float64\n",
      "3    float64\n",
      "4    float64\n",
      "5    float64\n",
      "6    float64\n",
      "7    float64\n",
      "8    float64\n",
      "9    float64\n",
      "dtypes: float64(10)\n",
      "memory usage: 880.0 bytes\n"
     ]
    }
   ],
   "source": [
    "pd.set_option('max_info_rows', 5)\n",
    "df4.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.772359</td>\n",
       "      <td>-1.536068</td>\n",
       "      <td>-0.802127</td>\n",
       "      <td>0.464856</td>\n",
       "      <td>1.240078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-2.620453</td>\n",
       "      <td>-1.764772</td>\n",
       "      <td>0.070110</td>\n",
       "      <td>-1.324331</td>\n",
       "      <td>1.422964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.644453</td>\n",
       "      <td>-0.702261</td>\n",
       "      <td>-0.414872</td>\n",
       "      <td>-0.256935</td>\n",
       "      <td>1.125648</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.908125</td>\n",
       "      <td>0.439317</td>\n",
       "      <td>0.792300</td>\n",
       "      <td>-0.392811</td>\n",
       "      <td>-0.555731</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-2.115850</td>\n",
       "      <td>-0.664434</td>\n",
       "      <td>-1.491068</td>\n",
       "      <td>0.104451</td>\n",
       "      <td>-0.963163</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4\n",
       "0  1.772359 -1.536068 -0.802127  0.464856  1.240078\n",
       "1 -2.620453 -1.764772  0.070110 -1.324331  1.422964\n",
       "2  0.644453 -0.702261 -0.414872 -0.256935  1.125648\n",
       "3  1.908125  0.439317  0.792300 -0.392811 -0.555731\n",
       "4 -2.115850 -0.664434 -1.491068  0.104451 -0.963163"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#6）定义精度：display.precision \n",
    "#display.precision sets the output display precision in terms of decimal places. This is only a suggestion.\n",
    "df5 = pd.DataFrame(np.random.randn(5, 5))\n",
    "pd.set_option('max_colwidth', 30) #设置每一个列宽\n",
    "df5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.772</td>\n",
       "      <td>-1.536</td>\n",
       "      <td>-0.802</td>\n",
       "      <td>0.465</td>\n",
       "      <td>1.240</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-2.620</td>\n",
       "      <td>-1.765</td>\n",
       "      <td>0.070</td>\n",
       "      <td>-1.324</td>\n",
       "      <td>1.423</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.644</td>\n",
       "      <td>-0.702</td>\n",
       "      <td>-0.415</td>\n",
       "      <td>-0.257</td>\n",
       "      <td>1.126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.908</td>\n",
       "      <td>0.439</td>\n",
       "      <td>0.792</td>\n",
       "      <td>-0.393</td>\n",
       "      <td>-0.556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-2.116</td>\n",
       "      <td>-0.664</td>\n",
       "      <td>-1.491</td>\n",
       "      <td>0.104</td>\n",
       "      <td>-0.963</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0      1      2      3      4\n",
       "0  1.772 -1.536 -0.802  0.465  1.240\n",
       "1 -2.620 -1.765  0.070 -1.324  1.423\n",
       "2  0.644 -0.702 -0.415 -0.257  1.126\n",
       "3  1.908  0.439  0.792 -0.393 -0.556\n",
       "4 -2.116 -0.664 -1.491  0.104 -0.963"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('precision', 3) #设置每一列的精度\n",
    "df5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.772359</td>\n",
       "      <td>-1.536068</td>\n",
       "      <td>-0.802127</td>\n",
       "      <td>0.464856</td>\n",
       "      <td>1.240078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-2.620453</td>\n",
       "      <td>-1.764772</td>\n",
       "      <td>0.070110</td>\n",
       "      <td>-1.324331</td>\n",
       "      <td>1.422964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.644453</td>\n",
       "      <td>-0.702261</td>\n",
       "      <td>-0.414872</td>\n",
       "      <td>-0.256935</td>\n",
       "      <td>1.125648</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.908125</td>\n",
       "      <td>0.439317</td>\n",
       "      <td>0.792300</td>\n",
       "      <td>-0.392811</td>\n",
       "      <td>-0.555731</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-2.115850</td>\n",
       "      <td>-0.664434</td>\n",
       "      <td>-1.491068</td>\n",
       "      <td>0.104451</td>\n",
       "      <td>-0.963163</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4\n",
       "0  1.772359 -1.536068 -0.802127  0.464856  1.240078\n",
       "1 -2.620453 -1.764772  0.070110 -1.324331  1.422964\n",
       "2  0.644453 -0.702261 -0.414872 -0.256935  1.125648\n",
       "3  1.908125  0.439317  0.792300 -0.392811 -0.555731\n",
       "4 -2.115850 -0.664434 -1.491068  0.104451 -0.963163"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.reset_option('precision') #可以通过reset_option来重置参数\n",
    "df5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.465130</td>\n",
       "      <td>-1.217467</td>\n",
       "      <td>-0.385065</td>\n",
       "      <td>0.452060</td>\n",
       "      <td>-1.047024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.704945</td>\n",
       "      <td>-1.114610</td>\n",
       "      <td>0.791910</td>\n",
       "      <td>1.229797</td>\n",
       "      <td>-0.994572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-1.419188</td>\n",
       "      <td>-0.481900</td>\n",
       "      <td>2.663729</td>\n",
       "      <td>-1.816895</td>\n",
       "      <td>0.886605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.049317</td>\n",
       "      <td>0.844350</td>\n",
       "      <td>1.969893</td>\n",
       "      <td>0.204883</td>\n",
       "      <td>0.332016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.442592</td>\n",
       "      <td>-1.697996</td>\n",
       "      <td>0.275920</td>\n",
       "      <td>1.611168</td>\n",
       "      <td>0.140293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.553236</td>\n",
       "      <td>-1.413901</td>\n",
       "      <td>1.293348</td>\n",
       "      <td>1.455726</td>\n",
       "      <td>0.752410</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-1.671353</td>\n",
       "      <td>-0.080426</td>\n",
       "      <td>-0.376666</td>\n",
       "      <td>-1.100079</td>\n",
       "      <td>0.111060</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2.375464</td>\n",
       "      <td>1.708105</td>\n",
       "      <td>0.090768</td>\n",
       "      <td>0.562754</td>\n",
       "      <td>1.902458</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           0         1         2         3         4\n",
       "0   1.465130 -1.217467 -0.385065  0.452060 -1.047024\n",
       "1  -0.704945 -1.114610  0.791910  1.229797 -0.994572\n",
       "2  -1.419188 -0.481900  2.663729 -1.816895  0.886605\n",
       "3   0.049317  0.844350  1.969893  0.204883  0.332016\n",
       "..       ...       ...       ...       ...       ...\n",
       "6   0.442592 -1.697996  0.275920  1.611168  0.140293\n",
       "7  -0.553236 -1.413901  1.293348  1.455726  0.752410\n",
       "8  -1.671353 -0.080426 -0.376666 -1.100079  0.111060\n",
       "9   2.375464  1.708105  0.090768  0.562754  1.902458\n",
       "\n",
       "[10 rows x 5 columns]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#7）设定阈值\n",
    "#display.chop_threshold sets at what level pandas rounds to zero when it displays a Series of DataFrame. Note, this does not effect the precision at which the number is stored.\n",
    "\n",
    "df6 = pd.DataFrame(np.random.randn(10, 5))\n",
    "pd.set_option('chop_threshold', 0)\n",
    "df6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.465130</td>\n",
       "      <td>-1.217467</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.047024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.704945</td>\n",
       "      <td>-1.114610</td>\n",
       "      <td>0.791910</td>\n",
       "      <td>1.229797</td>\n",
       "      <td>-0.994572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-1.419188</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.663729</td>\n",
       "      <td>-1.816895</td>\n",
       "      <td>0.886605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.844350</td>\n",
       "      <td>1.969893</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.697996</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.611168</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.553236</td>\n",
       "      <td>-1.413901</td>\n",
       "      <td>1.293348</td>\n",
       "      <td>1.455726</td>\n",
       "      <td>0.752410</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-1.671353</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.100079</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2.375464</td>\n",
       "      <td>1.708105</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.562754</td>\n",
       "      <td>1.902458</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           0         1         2         3         4\n",
       "0   1.465130 -1.217467  0.000000  0.000000 -1.047024\n",
       "1  -0.704945 -1.114610  0.791910  1.229797 -0.994572\n",
       "2  -1.419188  0.000000  2.663729 -1.816895  0.886605\n",
       "3   0.000000  0.844350  1.969893  0.000000  0.000000\n",
       "..       ...       ...       ...       ...       ...\n",
       "6   0.000000 -1.697996  0.000000  1.611168  0.000000\n",
       "7  -0.553236 -1.413901  1.293348  1.455726  0.752410\n",
       "8  -1.671353  0.000000  0.000000 -1.100079  0.000000\n",
       "9   2.375464  1.708105  0.000000  0.562754  1.902458\n",
       "\n",
       "[10 rows x 5 columns]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('chop_threshold', .5) #绝对值小于0.5的都设置为0\n",
    "df6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.465130</td>\n",
       "      <td>-1.217467</td>\n",
       "      <td>-0.385065</td>\n",
       "      <td>0.452060</td>\n",
       "      <td>-1.047024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.704945</td>\n",
       "      <td>-1.114610</td>\n",
       "      <td>0.791910</td>\n",
       "      <td>1.229797</td>\n",
       "      <td>-0.994572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-1.419188</td>\n",
       "      <td>-0.481900</td>\n",
       "      <td>2.663729</td>\n",
       "      <td>-1.816895</td>\n",
       "      <td>0.886605</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.049317</td>\n",
       "      <td>0.844350</td>\n",
       "      <td>1.969893</td>\n",
       "      <td>0.204883</td>\n",
       "      <td>0.332016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.442592</td>\n",
       "      <td>-1.697996</td>\n",
       "      <td>0.275920</td>\n",
       "      <td>1.611168</td>\n",
       "      <td>0.140293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.553236</td>\n",
       "      <td>-1.413901</td>\n",
       "      <td>1.293348</td>\n",
       "      <td>1.455726</td>\n",
       "      <td>0.752410</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-1.671353</td>\n",
       "      <td>-0.080426</td>\n",
       "      <td>-0.376666</td>\n",
       "      <td>-1.100079</td>\n",
       "      <td>0.111060</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2.375464</td>\n",
       "      <td>1.708105</td>\n",
       "      <td>0.090768</td>\n",
       "      <td>0.562754</td>\n",
       "      <td>1.902458</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           0         1         2         3         4\n",
       "0   1.465130 -1.217467 -0.385065  0.452060 -1.047024\n",
       "1  -0.704945 -1.114610  0.791910  1.229797 -0.994572\n",
       "2  -1.419188 -0.481900  2.663729 -1.816895  0.886605\n",
       "3   0.049317  0.844350  1.969893  0.204883  0.332016\n",
       "..       ...       ...       ...       ...       ...\n",
       "6   0.442592 -1.697996  0.275920  1.611168  0.140293\n",
       "7  -0.553236 -1.413901  1.293348  1.455726  0.752410\n",
       "8  -1.671353 -0.080426 -0.376666 -1.100079  0.111060\n",
       "9   2.375464  1.708105  0.090768  0.562754  1.902458\n",
       "\n",
       "[10 rows x 5 columns]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.reset_option('chop_threshold')\n",
    "df6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
